package org.demo.patten.memento;

/**
 * @author zhuj
 * @date 2025/3/29
 * @apiNote
 */
public class Main {
    public static void main(String[] args) {
        Editor editor = new Editor();
        EditorHistory history = new EditorHistory();
        editor.type("Hello World");
        history.save(editor);
        editor.type("Hello Design Patterns");
        history.save(editor);
        editor.type("Wrong content!");
        System.out.println("当前内容: " + editor.getContent()); // Wrong content!
        history.undo(editor);
        System.out.println("撤销1次: " + editor.getContent()); // Hello Design Patterns
        history.undo(editor);
        System.out.println("撤销2次: " + editor.getContent()); // Hello World
    }
}
